<?php

namespace common\models\kingdee;

use Yii;
use yii\behaviors\AttributeBehavior;
use yii\behaviors\AttributeTypecastBehavior;
use yii\db\ActiveRecord;

/**
 * This is the model class for table "T_ORG_ADMIN".
 *
 * @property string $FID
 * @property string $FNAME_L1
 * @property string $FNAME_L2
 * @property string $FNAME_L3
 * @property string $FNUMBER
 * @property string $FDESCRIPTION_L1
 * @property string $FDESCRIPTION_L2
 * @property string $FDESCRIPTION_L3
 * @property string $FSIMPLENAME
 * @property integer $FISGROUPING
 * @property string $FEFFECTDATE
 * @property string $FINVALIDDATE
 * @property integer $FISFREEZE
 * @property integer $FISCOMPANYORGUNIT
 * @property integer $FISADMINORGUNIT
 * @property integer $FISSALEORGUNIT
 * @property integer $FISPURCHASEORGUNIT
 * @property integer $FISSTORAGEORGUNIT
 * @property integer $FISPROFITORGUNIT
 * @property integer $FISCOSTORGUNIT
 * @property integer $FISCU
 * @property integer $FISUNION
 * @property integer $FISHRORGUNIT
 * @property string $FCREATORID
 * @property string $FCREATETIME
 * @property string $FLASTUPDATEUSERID
 * @property string $FLASTUPDATETIME
 * @property string $FCONTROLUNITID
 * @property integer $FISLEAF
 * @property integer $FLEVEL
 * @property string $FLONGNUMBER
 * @property string $FPARENTID
 * @property integer $FISENTITY
 * @property integer $FISVIRTUAL
 * @property string $FPHONENUMBER
 * @property string $FLAYERID
 * @property string $FRESPONPOSITIONID
 * @property string $FADDRESSID
 * @property string $FPRINCIPALID
 * @property string $FLAYERTYPEID
 * @property string $FBASEDUTY_L1
 * @property string $FBASEDUTY_L2
 * @property string $FBASEDUTY_L3
 * @property integer $FINDEX
 * @property string $FJOBSYSTEMID
 * @property string $FADMINADDRESS_L1
 * @property string $FADMINADDRESS_L2
 * @property string $FADMINADDRESS_L3
 * @property string $FZIPCODE
 * @property string $FFAX
 * @property integer $FISSEALUP
 * @property integer $FISSTART
 * @property integer $FISOUSEALUP
 * @property string $FDISPLAYNAME_L1
 * @property string $FDISPLAYNAME_L2
 * @property string $FDISPLAYNAME_L3
 * @property string $FPROPERTYSEALUPDATE
 * @property string $FVERSIONNUMBER
 * @property string $FCODE
 * @property integer $FISTRANSPORTORGUNIT
 * @property integer $FISQUALITYORGUNIT
 * @property string $FSORTCODE
 * @property string $FINDUSTRYID
 * @property integer $FECONOMICTYPE
 * @property string $FREGISTEREDCAPITAL
 * @property string $FREGISTEREDCODE
 * @property string $FSETUPDATE
 * @property string $FENDUPDATE
 * @property string $FTAXNUMBER
 * @property integer $FISCHURCHYARD
 * @property string $FJURIDICALPERSONID
 * @property integer $FISJURIDICALCOMPANY
 * @property integer $FISINDEPENDENCE
 * @property string $FTERRITORY_L1
 * @property string $FTERRITORY_L2
 * @property string $FTERRITORY_L3
 * @property string $FORGCODE
 * @property string $FAREAID
 * @property string $FORGPROPERTYID
 * @property string $FREGISTTYPEID
 * @property string $FEFFDT
 * @property string $FLEFFDT
 * @property string $FHISTORYRELATEID
 * @property string $FDELEGATEHRID
 * @property string $FORGFUNCTIONID
 * @property string $FCOMPANYID
 * @property string $FDEPARTMENTID
 * @property string $FOFFICEID
 * @property string $FLEVELFOURGROUPID
 * @property string $FLEVELFIVEGROUPID
 * @property string $FLEVELFIVEGROUP
 * @property string $FLEVELSIXGROUPID
 * @property string $FRESERVEFIELDFIRST
 * @property string $FRESERVEFIELDSECOND
 * @property string $FRESERVEITEMFIRST
 * @property string $FRESERVEITEMSECOND
 * @property integer $FISSTARTSHR
 * @property string $FORGTYPESTR
 */
class OrgAdmin extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'T_ORG_ADMIN';
    }

    /**
     * @return \yii\db\Connection the database connection used by this AR class.
     */
    public static function getDb()
    {
        return Yii::$app->get('db_hr');
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['FID'], 'required'],
            [['FISGROUPING', 'FISFREEZE', 'FISCOMPANYORGUNIT', 'FISADMINORGUNIT', 'FISSALEORGUNIT', 'FISPURCHASEORGUNIT', 'FISSTORAGEORGUNIT', 'FISPROFITORGUNIT', 'FISCOSTORGUNIT', 'FISCU', 'FISUNION', 'FISHRORGUNIT', 'FISLEAF', 'FLEVEL', 'FISENTITY', 'FISVIRTUAL', 'FINDEX', 'FISSEALUP', 'FISSTART', 'FISOUSEALUP', 'FISTRANSPORTORGUNIT', 'FISQUALITYORGUNIT', 'FECONOMICTYPE', 'FISCHURCHYARD', 'FISJURIDICALCOMPANY', 'FISINDEPENDENCE', 'FISSTARTSHR'], 'integer'],
            [['FEFFECTDATE', 'FINVALIDDATE', 'FCREATETIME', 'FLASTUPDATETIME', 'FPROPERTYSEALUPDATE', 'FSETUPDATE', 'FENDUPDATE', 'FEFFDT', 'FLEFFDT'], 'safe'],
            [['FREGISTEREDCAPITAL'], 'number'],
            [['FID', 'FCREATORID', 'FLASTUPDATEUSERID', 'FCONTROLUNITID', 'FPARENTID', 'FLAYERID', 'FRESPONPOSITIONID', 'FADDRESSID', 'FPRINCIPALID', 'FLAYERTYPEID', 'FJOBSYSTEMID', 'FINDUSTRYID', 'FJURIDICALPERSONID', 'FAREAID', 'FORGPROPERTYID', 'FREGISTTYPEID', 'FHISTORYRELATEID', 'FDELEGATEHRID', 'FORGFUNCTIONID', 'FCOMPANYID', 'FDEPARTMENTID', 'FOFFICEID', 'FLEVELFOURGROUPID', 'FLEVELFIVEGROUPID', 'FLEVELFIVEGROUP', 'FLEVELSIXGROUPID', 'FRESERVEFIELDFIRST', 'FRESERVEFIELDSECOND', 'FRESERVEITEMFIRST', 'FRESERVEITEMSECOND'], 'string', 'max' => 44],
            [['FNAME_L1', 'FNAME_L2', 'FNAME_L3', 'FDESCRIPTION_L1', 'FDESCRIPTION_L2', 'FDESCRIPTION_L3', 'FBASEDUTY_L1', 'FBASEDUTY_L2', 'FBASEDUTY_L3', 'FSORTCODE', 'FORGTYPESTR'], 'string', 'max' => 765],
            [['FNUMBER', 'FSIMPLENAME', 'FPHONENUMBER', 'FCODE', 'FREGISTEREDCODE', 'FTAXNUMBER', 'FTERRITORY_L1', 'FTERRITORY_L2', 'FTERRITORY_L3'], 'string', 'max' => 240],
            [['FLONGNUMBER', 'FDISPLAYNAME_L1', 'FDISPLAYNAME_L2', 'FDISPLAYNAME_L3'], 'string', 'max' => 600],
            [['FADMINADDRESS_L1', 'FADMINADDRESS_L2', 'FADMINADDRESS_L3'], 'string', 'max' => 100],
            [['FZIPCODE', 'FFAX'], 'string', 'max' => 20],
            [['FVERSIONNUMBER'], 'string', 'max' => 3],
            [['FORGCODE'], 'string', 'max' => 300],
            [['FID', 'FID', 'FID', 'FID'], 'unique', 'targetAttribute' => ['FID', 'FID', 'FID', 'FID'], 'message' => 'The combination of  and Fid has already been taken.'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'FID' => Yii::t('kingdee', 'Fid'),
            'FNAME_L1' => Yii::t('kingdee', 'Fname  L1'),
            'FNAME_L2' => Yii::t('kingdee', 'Fname  L2'),
            'FNAME_L3' => Yii::t('kingdee', 'Fname  L3'),
            'FNUMBER' => Yii::t('kingdee', 'Fnumber'),
            'FDESCRIPTION_L1' => Yii::t('kingdee', 'Fdescription  L1'),
            'FDESCRIPTION_L2' => Yii::t('kingdee', 'Fdescription  L2'),
            'FDESCRIPTION_L3' => Yii::t('kingdee', 'Fdescription  L3'),
            'FSIMPLENAME' => Yii::t('kingdee', 'Fsimplename'),
            'FISGROUPING' => Yii::t('kingdee', 'Fisgrouping'),
            'FEFFECTDATE' => Yii::t('kingdee', 'Feffectdate'),
            'FINVALIDDATE' => Yii::t('kingdee', 'Finvaliddate'),
            'FISFREEZE' => Yii::t('kingdee', 'Fisfreeze'),
            'FISCOMPANYORGUNIT' => Yii::t('kingdee', 'Fiscompanyorgunit'),
            'FISADMINORGUNIT' => Yii::t('kingdee', 'Fisadminorgunit'),
            'FISSALEORGUNIT' => Yii::t('kingdee', 'Fissaleorgunit'),
            'FISPURCHASEORGUNIT' => Yii::t('kingdee', 'Fispurchaseorgunit'),
            'FISSTORAGEORGUNIT' => Yii::t('kingdee', 'Fisstorageorgunit'),
            'FISPROFITORGUNIT' => Yii::t('kingdee', 'Fisprofitorgunit'),
            'FISCOSTORGUNIT' => Yii::t('kingdee', 'Fiscostorgunit'),
            'FISCU' => Yii::t('kingdee', 'Fiscu'),
            'FISUNION' => Yii::t('kingdee', 'Fisunion'),
            'FISHRORGUNIT' => Yii::t('kingdee', 'Fishrorgunit'),
            'FCREATORID' => Yii::t('kingdee', 'Fcreatorid'),
            'FCREATETIME' => Yii::t('kingdee', 'Fcreatetime'),
            'FLASTUPDATEUSERID' => Yii::t('kingdee', 'Flastupdateuserid'),
            'FLASTUPDATETIME' => Yii::t('kingdee', 'Flastupdatetime'),
            'FCONTROLUNITID' => Yii::t('kingdee', 'Fcontrolunitid'),
            'FISLEAF' => Yii::t('kingdee', 'Fisleaf'),
            'FLEVEL' => Yii::t('kingdee', 'Flevel'),
            'FLONGNUMBER' => Yii::t('kingdee', 'Flongnumber'),
            'FPARENTID' => Yii::t('kingdee', 'Fparentid'),
            'FISENTITY' => Yii::t('kingdee', 'Fisentity'),
            'FISVIRTUAL' => Yii::t('kingdee', 'Fisvirtual'),
            'FPHONENUMBER' => Yii::t('kingdee', 'Fphonenumber'),
            'FLAYERID' => Yii::t('kingdee', 'Flayerid'),
            'FRESPONPOSITIONID' => Yii::t('kingdee', 'Fresponpositionid'),
            'FADDRESSID' => Yii::t('kingdee', 'Faddressid'),
            'FPRINCIPALID' => Yii::t('kingdee', 'Fprincipalid'),
            'FLAYERTYPEID' => Yii::t('kingdee', 'Flayertypeid'),
            'FBASEDUTY_L1' => Yii::t('kingdee', 'Fbaseduty  L1'),
            'FBASEDUTY_L2' => Yii::t('kingdee', 'Fbaseduty  L2'),
            'FBASEDUTY_L3' => Yii::t('kingdee', 'Fbaseduty  L3'),
            'FINDEX' => Yii::t('kingdee', 'Findex'),
            'FJOBSYSTEMID' => Yii::t('kingdee', 'Fjobsystemid'),
            'FADMINADDRESS_L1' => Yii::t('kingdee', 'Fadminaddress  L1'),
            'FADMINADDRESS_L2' => Yii::t('kingdee', 'Fadminaddress  L2'),
            'FADMINADDRESS_L3' => Yii::t('kingdee', 'Fadminaddress  L3'),
            'FZIPCODE' => Yii::t('kingdee', 'Fzipcode'),
            'FFAX' => Yii::t('kingdee', 'Ffax'),
            'FISSEALUP' => Yii::t('kingdee', 'Fissealup'),
            'FISSTART' => Yii::t('kingdee', 'Fisstart'),
            'FISOUSEALUP' => Yii::t('kingdee', 'Fisousealup'),
            'FDISPLAYNAME_L1' => Yii::t('kingdee', 'Fdisplayname  L1'),
            'FDISPLAYNAME_L2' => Yii::t('kingdee', 'Fdisplayname  L2'),
            'FDISPLAYNAME_L3' => Yii::t('kingdee', 'Fdisplayname  L3'),
            'FPROPERTYSEALUPDATE' => Yii::t('kingdee', 'Fpropertysealupdate'),
            'FVERSIONNUMBER' => Yii::t('kingdee', 'Fversionnumber'),
            'FCODE' => Yii::t('kingdee', 'Fcode'),
            'FISTRANSPORTORGUNIT' => Yii::t('kingdee', 'Fistransportorgunit'),
            'FISQUALITYORGUNIT' => Yii::t('kingdee', 'Fisqualityorgunit'),
            'FSORTCODE' => Yii::t('kingdee', 'Fsortcode'),
            'FINDUSTRYID' => Yii::t('kingdee', 'Findustryid'),
            'FECONOMICTYPE' => Yii::t('kingdee', 'Feconomictype'),
            'FREGISTEREDCAPITAL' => Yii::t('kingdee', 'Fregisteredcapital'),
            'FREGISTEREDCODE' => Yii::t('kingdee', 'Fregisteredcode'),
            'FSETUPDATE' => Yii::t('kingdee', 'Fsetupdate'),
            'FENDUPDATE' => Yii::t('kingdee', 'Fendupdate'),
            'FTAXNUMBER' => Yii::t('kingdee', 'Ftaxnumber'),
            'FISCHURCHYARD' => Yii::t('kingdee', 'Fischurchyard'),
            'FJURIDICALPERSONID' => Yii::t('kingdee', 'Fjuridicalpersonid'),
            'FISJURIDICALCOMPANY' => Yii::t('kingdee', 'Fisjuridicalcompany'),
            'FISINDEPENDENCE' => Yii::t('kingdee', 'Fisindependence'),
            'FTERRITORY_L1' => Yii::t('kingdee', 'Fterritory  L1'),
            'FTERRITORY_L2' => Yii::t('kingdee', 'Fterritory  L2'),
            'FTERRITORY_L3' => Yii::t('kingdee', 'Fterritory  L3'),
            'FORGCODE' => Yii::t('kingdee', 'Forgcode'),
            'FAREAID' => Yii::t('kingdee', 'Fareaid'),
            'FORGPROPERTYID' => Yii::t('kingdee', 'Forgpropertyid'),
            'FREGISTTYPEID' => Yii::t('kingdee', 'Fregisttypeid'),
            'FEFFDT' => Yii::t('kingdee', 'Feffdt'),
            'FLEFFDT' => Yii::t('kingdee', 'Fleffdt'),
            'FHISTORYRELATEID' => Yii::t('kingdee', 'Fhistoryrelateid'),
            'FDELEGATEHRID' => Yii::t('kingdee', 'Fdelegatehrid'),
            'FORGFUNCTIONID' => Yii::t('kingdee', 'Forgfunctionid'),
            'FCOMPANYID' => Yii::t('kingdee', 'Fcompanyid'),
            'FDEPARTMENTID' => Yii::t('kingdee', 'Fdepartmentid'),
            'FOFFICEID' => Yii::t('kingdee', 'Fofficeid'),
            'FLEVELFOURGROUPID' => Yii::t('kingdee', 'Flevelfourgroupid'),
            'FLEVELFIVEGROUPID' => Yii::t('kingdee', 'Flevelfivegroupid'),
            'FLEVELFIVEGROUP' => Yii::t('kingdee', 'Flevelfivegroup'),
            'FLEVELSIXGROUPID' => Yii::t('kingdee', 'Flevelsixgroupid'),
            'FRESERVEFIELDFIRST' => Yii::t('kingdee', 'Freservefieldfirst'),
            'FRESERVEFIELDSECOND' => Yii::t('kingdee', 'Freservefieldsecond'),
            'FRESERVEITEMFIRST' => Yii::t('kingdee', 'Freserveitemfirst'),
            'FRESERVEITEMSECOND' => Yii::t('kingdee', 'Freserveitemsecond'),
            'FISSTARTSHR' => Yii::t('kingdee', 'Fisstartshr'),
            'FORGTYPESTR' => Yii::t('kingdee', 'Forgtypestr'),
        ];
    }

    public function getPrintName(){
        return sprintf('名称: %s', $this->FNAME_L2);
    }

//    public function behaviors()
//    {
//        return [
//            [
//                'class' => AttributeBehavior::className(),
//                'attributes' => [
//                    ActiveRecord::EVENT_BEFORE_UPDATE => ['FEFFDT'],
//                ],
//                'value' => function ($event) {
////                    preg_match('/(?<d>\d{2})-(?<m>\d{1,2})月\s*-(?<y>\d{2})/',$this->FEFFDT,$m);
////                    return date('Y-m-d',strtotime($m['y'].'-'.$m['m'].'-'.$m['d']));
//                    $returnValue = sprintf('to_timestamp(\'%s\' , \'yyyy-MM-dd\')', $this->FEFFDT);
////                    $unixTime = strtotime($this->FEFFDT);
////                    $returnValue = sprintf('FROM_UNIXTIME(%s)', $unixTime);
//                    return $returnValue;
//                },
//            ],
//            [
//                'class' => AttributeBehavior::className(),
//                'attributes' => [
//                    ActiveRecord::EVENT_BEFORE_UPDATE => ['FLEFFDT'],
//                ],
//                'value' => function ($event) {
//                    $returnValue = sprintf('to_timestamp(\'%s\' , \'yyyy-MM-dd\')', $this->FLEFFDT);
////                    $unixTime = strtotime($this->FLEFFDT);
////                    $returnValue = sprintf('FROM_UNIXTIME(%s)', $unixTime);
//                    return $returnValue;
//                },
//            ],
//        ];
//    }
}
